<div class="input-append">
	<input id="${tree_id!''}Id" name="${tree_name!''}" class="${tree_cssClass!''}" type="hidden" value="${tree_value!''}"/>
	<input id="${tree_id!''}Name" name="${tree_labelName!''}" <#if tree_allowInput??> readonly="readonly" </#if> type="text" value="${tree_labelValue!''}" data-msg-required="${tree_dataMsgRequired!''}"
		class="${tree_cssClass!''}" style="${tree_cssStyle!''}"/><a id="${tree_id!''}Button" href="javascript:" class="btn ${tree_disabled!''} <#if tree_hideBtn??> hide </#if>" <#if tree_smallBtn??> style="padding:4px 2px;" </#if>>&nbsp;<i class="icon-search"></i>&nbsp;</a>&nbsp;&nbsp;
</div>
<script type="text/javascript">
	$("#${tree_id!''}Button, #${tree_id!''}Name").click(function(){
		// 是否限制选择，如果限制，设置为disabled
		if ($("#${tree_id!''}Button").hasClass("disabled")){
			return true;
		}
		// 正常打开	
		top.$.jBox.open("iframe:/tag/treeselect?url="+encodeURIComponent("${tree_url!''}")+"&module=${tree_module!''}&checked=${tree_checked!''}&extId=${tree_extId!''}&isAll=${tree_isAll!''}", "选择${tree_title!''}", 300, 420, {
			ajaxData:{selectIds: $("#${tree_id!''}Id").val()},buttons:{"确定":"ok", <#if tree_allowClear??>"清除":"clear", </#if> "关闭":true}, submit:function(v, h, f){
				if (v=="ok"){
					var tree = h.find("iframe")[0].contentWindow.tree;
					var ids = [], names = [], nodes = [];
					if ("${tree_checked!''}" == "true"){
						nodes = tree.getCheckedNodes(true);
					}else{
						nodes = tree.getSelectedNodes();
					}
/* 					alert(nodes[nodes.length-1].id);
					alert(nodes[nodes.length-1].name); */
					$("#${tree_id!''}Id").val(nodes[nodes.length-1].id);
					$("#${tree_id!''}Name").val(nodes[nodes.length-1].name);
					/* for(var i=0; i<nodes.length; i++) {
						if (nodes[i].isParent){
							continue; 
						}
						if (nodes[i].level == 0){
							top.$.jBox.tip("不能选择根节点（"+nodes[i].name+"）请重新选择。");
							return false;
						}
						if (nodes[i].isParent){
							top.$.jBox.tip("不能选择父节点（"+nodes[i].name+"）请重新选择。");
							return false;
						}
						if (nodes[i].module == ""){
							top.$.jBox.tip("不能选择公共模型（"+nodes[i].name+"）请重新选择。");
							return false;
						}else if (nodes[i].module != "${tree_module!''}"){
							top.$.jBox.tip("不能选择当前栏目以外的栏目模型，请重新选择。");
							return false;
						}
						ids.push(nodes[i].id);
						names.push(nodes[i].name);
						break; // 如果为非复选框选择，则返回第一个选择 
					}
					$("#${tree_id!''}Id").val(ids.join(",").replace(/u_/ig,""));
					$("#${tree_id!''}Name").val(names.join(",")); */
				}
				else if (v=="clear"){
					$("#${tree_id!''}Id").val("");
					$("#${tree_id!''}Name").val("");
                }
				if(typeof ${tree_id!''}TreeselectCallBack == 'function'){
					${tree_id!''}TreeselectCallBack(v, h, f);
				}
			}, loaded:function(h){
				$(".jbox-content", top.document).css("overflow-y","hidden");
			}
		});
	});
</script>